using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class SegmentGroupAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public SegmentGroupAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v24] = new string[]{"PIDG","OBRG","ORCG","RXAG","RXDG","RXEG","RXOG","etc"};
						validVersionCodes[HL7Version.v25] = new string[]{"PIDG","OBRG","ORCG","RXAG","RXDG","RXEG","RXOG"};
						validVersionCodes[HL7Version.v251] = new string[]{"PIDG","OBRG","ORCG","RXAG","RXDG","RXEG","RXOG"};
						validVersionCodes[HL7Version.v26] = new string[]{"ADMINISTRATION","ALLERGY","APP_STATS","APP_STATUS","ASSOCIATED_PERSON","ASSOCIATED_RX_ADMIN","ASSOCIATED_RX_ORDER","AUTHORIZATION","AUTHORIZATION_CONTACT","CERTIFICATE","CLOCK","CLOCK_AND_STATISTICS","CLOCK_AND_STATS_WITH_NOTE","COMMAND","COMMAND_RESPONSE","COMMON_ORDER","COMPONENT","COMPONENTS","CONTAINER","DEFINITION","DIET","DISPENSE","ENCODED ORDER","ENCODED_ORDER","ENCODING","EXPERIENCE","FINANCIAL","FINANCIAL_COMMON ORDER","FINANCIAL_INSURANCE","FINANCIAL_OBSERVATION","FINANCIAL_ORDER","FINANCIAL_PROCEDURE","FINANCIAL_TIMING QUANTITY","FINANCIAL_TIMING_QUANTITY","GENERAL RESOURCE","GENERAL_RESOURCE","GIVE","GOAL","GOAL_OBSERVATION","GOAL_PATHWAY","GOAL_ROLE","GUARANTOR_INSURANCE","INSURANCE","LOCATION RESOURCE","LOCATION_RESOURCE","MERGE_INFO","MF","MF_CDM","MF_CLIN_STUDY","MF_CLIN_STUDY_SCHED","MF_INV_ITEM","MF_LOC_DEPT","MF_LOCATION","MF_OBS_ATTRIBUTES","MF_PHASE_SCHED_DETAIL","MF_QUERY","MF_SITE_DEFINED","MF_STAFF","MF_TEST","MF_TEST_BATT_DETAIL","MF_TEST_BATTERIES","MF_TEST_CALC_DETAIL","MF_TEST_CALCULATED","MF_TEST_CAT_DETAIL","MF_TEST_CATEGORICAL","MF_TEST_NUMERIC","NK1_TIMING_QTY","NOTIFICATION","OBSERVATION","OBSERVATION_PRIOR","OBSERVATION_REQUEST","OMSERVATION","ORDER","ORDER_CHOICE","ORDER_DETAIL","ORDER_DETAIL_SUPPLEMENT","ORDER_DIET","ORDER_ENCODED","ORDER_OBSERVATION","ORDER_PRIOR","ORDER_TRAY","PATHWAY","PATHWAY_ROLE","PATIENT","PATIENT VISIT","PATIENT_PRIOR","PATIENT_RESULT","PATIENT_VISIT","PATIENT_VISIT_PRIOR","PERSONNEL RESOURCE","PERSONNEL_RESOURCE","PEX_CAUSE","PEX_OBSERVATION","PRIOR_RESULT","PROBLEM","PROBLEM_OBSERVATION","PROBLEM_PATHWAY","PROBLEM_ROLE","PROCEDURE","PRODUCT","PRODUCT_STATUS","PROVIDER","PROVIDER_CONTACT","QBP","QRY_WITH_DETAIL","QUERY_RESPONSE","QUERY_RESULT_CLUSTER","REQUEST","RESOURCE","RESOURCES","RESPONSE","RESULT","RESULTS","RESULTS_NOTES","ROW_DEFINITION","RX_ADMINISTRATION","RX_ORDER","SCHEDULE","SERVICE","SPECIMEN","SPECIMEN_CONTAINER","STAFF","STUDY","STUDY_OBSERVATION","STUDY_PHASE","STUDY_SCHEDULE","TEST_CONFIGURATION","TIMING","TIMING_DIET","TIMING_ENCODED","TIMING_GIVE","TIMING_PRIOR","TIMING_QTY","TIMING_QUANTITY","TIMING_TRAY","TREATMENT","VISIT"};
						validVersionCodes[HL7Version.v27] = new string[]{"ADMINISTRATION","ALLERGY","APP_STATS","APP_STATUS","ASSOCIATED_PERSON","ASSOCIATED_RX_ADMIN","ASSOCIATED_RX_ORDER","AUTHORIZATION","AUTHORIZATION_CONTACT","CERTIFICATE","CLOCK","CLOCK_AND_STATISTICS","CLOCK_AND_STATS_WITH_NOTE","COMMAND","COMMAND_RESPONSE","COMMON_ORDER","COMPONENT","COMPONENTS","CONTAINER","DEFINITION","DIET","DISPENSE","ENCODED_ORDER","ENCODING","EXPERIENCE","FINANCIAL","FINANCIAL_COMMON_ORDER","FINANCIAL_INSURANCE","FINANCIAL_OBSERVATION","FINANCIAL_ORDER","FINANCIAL_PROCEDURE","FINANCIAL_TIMING_QUANTITY","GENERAL_RESOURCE","GIVE","GOAL","GOAL_OBSERVATION","GOAL_PATHWAY","GOAL_ROLE","GUARANTOR_INSURANCE","INSURANCE","LOCATION_RESOURCE","MERGE_INFO","MF","MF_CDM","MF_CLIN_STUDY","MF_CLIN_STUDY_SCHED","MF_INV_ITEM","MF_LOC_DEPT","MF_LOCATION","MF_OBS_ATTRIBUTES","MF_PHASE_SCHED_DETAIL","MF_QUERY","MF_SITE_DEFINED","MF_STAFF","MF_TEST","MF_TEST_BATT_DETAIL","MF_TEST_BATTERIES","MF_TEST_CALC_DETAIL","MF_TEST_CALCULATED","MF_TEST_CAT_DETAIL","MF_TEST_CATEGORICAL","MF_TEST_NUMERIC","NK1_TIMING_QTY","NOTIFICATION","OBSERVATION","OBSERVATION_PRIOR","OBSERVATION_REQUEST","OMSERVATION","ORDER","ORDER_CHOICE","ORDER_DETAIL","ORDER_DETAIL_SUPPLEMENT","ORDER_DIET","ORDER_ENCODED","ORDER_OBSERVATION","ORDER_PRIOR","ORDER_TRAY","PATHWAY","PATHWAY_ROLE","PATIENT","PATIENT_PRIOR","PATIENT_RESULT","PATIENT_VISIT","PATIENT_VISIT_PRIOR","PERSONNEL_RESOURCE","PEX_CAUSE","PEX_OBSERVATION","PRIOR_RESULT","PROBLEM","PROBLEM_OBSERVATION","PROBLEM_PATHWAY","PROBLEM_ROLE","PROCEDURE","PRODUCT","PRODUCT_STATUS","PROVIDER","PROVIDER_CONTACT","QBP","QRY_WITH_DETAIL","QUERY_RESPONSE","QUERY_RESULT_CLUSTER","REQUEST","RESOURCE","RESOURCES","RESPONSE","RESULT","RESULTS","RESULTS_NOTES","ROW_DEFINITION","RX_ADMINISTRATION","RX_ORDER","SCHEDULE","SERVICE","SPECIMEN","SPECIMEN_CONTAINER","STAFF","STUDY","STUDY_OBSERVATION","STUDY_PHASE","STUDY_SCHEDULE","TEST_CONFIGURATION","TIMING","TIMING_DIET","TIMING_ENCODED","TIMING_GIVE","TIMING_PRIOR","TIMING_QTY","TIMING_QUANTITY","TIMING_TRAY","TREATMENT","VISIT"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v24] = new string[]{"PID group","OBR group","ORC group","RXA group","RXD group","RXE group","RXO group",""};
						validVersionDescriptions[HL7Version.v25] = new string[]{"PID group","OBR group","ORC group","RXA group","RXD group","RXE group","RXO group"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"PID group","OBR group","ORC group","RXA group","RXD group","RXE group","RXO group"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""};
						validVersionDescriptions[HL7Version.v27] = new string[]{"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
